package org.hawk.gwtppc.webtest.tests.constructorsuite;

import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.List;

import org.hawk.gwtppc.webtest.common.Asserts;
import org.hawk.gwtppc.webtest.common.Test;
import org.hawk.gwtppc.webtest.tests.mock.ClassMock;
import org.hawk.gwtppc.webtest.tests.mock.EnumMock;
import org.hawk.gwtppc.webtest.tests.mock.GenericClassMock;
import org.hawk.gwtppc.webtest.tests.mock.SubClassMock2;

public class GetParameterTypesTest implements Test {

	public void run() throws Throwable {
		Asserts.assertTrue(Arrays.equals(EnumMock.class.getDeclaredConstructor(String.class,int.class).getParameterTypes(), 
					new Class[]{ String.class, int.class }), 
				"Wrong types: " + Arrays.toString(EnumMock.class.getDeclaredConstructor(String.class,int.class).getParameterTypes()));
		
		Asserts.assertEquals(ClassMock.class.getDeclaredConstructor().getParameterTypes().length, 0);
		
		Asserts.assertTrue(Arrays.equals(SubClassMock2.class.getDeclaredConstructor(String.class).getParameterTypes(), new Class[]{ String.class}), 
			"Wrong types: " + Arrays.toString(SubClassMock2.class.getDeclaredConstructor(String.class).getParameterTypes()));
		
		@SuppressWarnings("rawtypes")
		Constructor<GenericClassMock> constructor = GenericClassMock.class.getDeclaredConstructor(List.class, CharSequence.class, 
				Object.class, Object.class);
		Asserts.assertTrue(Arrays.equals(constructor.getParameterTypes(), new Class[]{ List.class, CharSequence.class, 
			Object.class, Object.class }), "Wrong types: " + Arrays.toString(constructor.getParameterTypes()));
	}

	public String getName() {
		return "getParameterTypes()";
	}

}
